package com.ruoyi.web.controller.epm;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EpmInformationResignationRecord;
import com.ruoyi.system.service.IEpmInformationResignationRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 离职记录Controller
 * 
 * @author ruoyi
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/resignation_record/resignation_record")
public class EpmInformationResignationRecordController extends BaseController
{
    @Autowired
    private IEpmInformationResignationRecordService epmInformationResignationRecordService;

    /**
     * 查询离职记录列表
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpmInformationResignationRecord epmInformationResignationRecord)
    {
        startPage();
        List<EpmInformationResignationRecord> list = epmInformationResignationRecordService.selectEpmInformationResignationRecordList(epmInformationResignationRecord);
        return getDataTable(list);
    }

    /**
     * 导出离职记录列表
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:export')")
    @Log(title = "离职记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpmInformationResignationRecord epmInformationResignationRecord)
    {
        List<EpmInformationResignationRecord> list = epmInformationResignationRecordService.selectEpmInformationResignationRecordList(epmInformationResignationRecord);
        ExcelUtil<EpmInformationResignationRecord> util = new ExcelUtil<EpmInformationResignationRecord>(EpmInformationResignationRecord.class);
        util.exportExcel(response, list, "离职记录数据");
    }

    /**
     * 获取离职记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(epmInformationResignationRecordService.selectEpmInformationResignationRecordById(id));
    }

    /**
     * 新增离职记录
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:add')")
    @Log(title = "离职记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpmInformationResignationRecord epmInformationResignationRecord)
    {
        return toAjax(epmInformationResignationRecordService.insertEpmInformationResignationRecord(epmInformationResignationRecord));
    }

    /**
     * 修改离职记录
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:edit')")
    @Log(title = "离职记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpmInformationResignationRecord epmInformationResignationRecord)
    {
        return toAjax(epmInformationResignationRecordService.updateEpmInformationResignationRecord(epmInformationResignationRecord));
    }

    /**
     * 删除离职记录
     */
    @PreAuthorize("@ss.hasPermi('Empment:resignation_record:remove')")
    @Log(title = "离职记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(epmInformationResignationRecordService.deleteEpmInformationResignationRecordByIds(ids));
    }
}
